package com.example.hbase.web;

import com.example.hbase.util.HbaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author xxg
 */
@RestController
public class IndexController {

@Autowired
HbaseUtil hbaseUtil;
    @GetMapping("index")
    public Object test(){
        return "hello hbase";
    }

    @GetMapping("exist")
    public  boolean exist(String tableName){
      return   hbaseUtil.isTableExist(tableName);
    }

    @GetMapping("create")
    public  boolean create(String tableName,String family){
        return   hbaseUtil.createTable(tableName,family==null?null:family.split(","));
    }
    @GetMapping("getTables")
    public  Object getTables() throws IOException {
        return   hbaseUtil.getTables();
    }

}
